package com.younion.business.impl;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.younion.business.ILoginService;
import com.younion.business.IUserService;
import com.younion.common.exception.BaseException;
import com.younion.vo.UserVO;

/**
 * @Title: LoginServiceImpl.java
 * @Package com.younion.business
 * @author seagull
 * @date Sep 12, 2012 10:17:57 AM
 */

public class LoginServiceImpl implements ILoginService {

	private IUserService userService;

	public boolean login(UserVO user) throws BaseException {
		if (user == null)
			return false;
		Map paramMap = new HashMap();
		paramMap.put("account", user.getAccount());
		paramMap.put("password", user.getPassword());
		int count = userService.getCountByMap(paramMap);
		if (count > 0) {
			return true;
		}
		return false;
	}

	public boolean isEixsts(String userAccount) throws BaseException {
		if (StringUtils.isEmpty(userAccount)) {
			return false;
		}
		Map paramMap = new HashMap();
		paramMap.put("account", userAccount);
		int count = userService.getCountByMap(paramMap);
		if (count > 0) {
			return true;
		}
		return false;
	}

	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

}
